const xxx = [
  {
    desc: "眼睛很难说谎🎧 ༘",
    id: 1,
    statistics: {
      admire_count: 0,
      collect_count: 79628,
      comment_count: 91412,
      digg_count: 2792912,
      play_count: 0,
      share_count: 167988,
    },
    avatar:"https://p3-pc.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_31589976a8790e475243be1ec4e24141~c5_168x168.jpeg?from=2956013662",
    nickname: "刘思瑶nice",
    video_url: "https://www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cinsbrrc77ua1lo05q8g&line=0&file_id=821fd96bdb844a529d72e35616633bea&sign=7aa8ef04fc349351a93857bc66dede88&is_play_url=1&source=PackSourceEnum_PUBLISH",
  },
  {
    desc: "把东方美学带到欧洲 #卢浮宫\n#马面裙",
    id: 99,
    statistics: {
      admire_count: 679,
      collect_count: 245585,
      comment_count: 136284,
      digg_count: 6400077,
      play_count: 0,
      share_count: 446468,
    },
    avatar:"https://p3-pc.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_99d3a4923c94e1e27b16209743eaec24~c5_300x300.jpeg?from=2956013662",
    nickname: "彭十六elf",
    video_url: "https://www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cjdk9q3c77ud1oonqoqg&line=0&file_id=b636323c468d42df8b21695bb124d9ee&sign=5786da50100031a108d24a9ef596de33&is_play_url=1&source=PackSourceEnum_PUBLISH",
  },
  {
    desc: "#帅帅的大男孩舞蹈",
    id: 3,
    statistics: {
      admire_count: 11,
      collect_count: 39090,
      comment_count: 14468,
      digg_count: 361226,
      play_count: 0,
      share_count: 304604,
    },
    avatar:"https://p3-pc.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_c7784af3a0bd2e7c5fc92ece450f12e0~c5_168x168.jpeg?from=2956013662",
    nickname: "奶茶妹◕🌱",
    video_url: "https://www.douyin.com/aweme/v1/play/?video_id=v0300fg10000cambmmjc77u9qb0i0cqg&line=0&file_id=cae9ebb5eda04242862d0944c1cb91a1&sign=918f1ee6d41643343153beded9c750ff&is_play_url=1&source=PackSourceEnum_PUBLISH",
  },
  {
    desc: "舒服自在 心情可爱",
    id: 4,
    statistics: {
      admire_count: 0,
      collect_count: 128162,
      comment_count: 90107,
      digg_count: 2484136,
      play_count: 0,
      share_count: 337108,
    },
    avatar:"https://p3-pc.douyinpic.com/img/aweme-avatar/tos-cn-avt-0015_31589976a8790e475243be1ec4e24141~c5_168x168.jpeg?from=2956013662",
    nickname: "刘思瑶nice",
    video_url: "https://www.douyin.com/aweme/v1/play/?video_id=v0200fg10000cfchocjc77u067mjilm0&line=0&file_id=805ad6fd235a4de6b40a328ef5dd2b02&sign=beaf8e329f41389bea0902d238c08351&is_play_url=1&source=PackSourceEnum_PUBLISH",
  },
  {
    desc: "豌豆大丰收！得闲把豌豆吃食都做个遍——豌豆凉粉和豌豆黄 #美食趣胃计划",
    id: 5,
    statistics: {
      admire_count: 0,
      collect_count: 1971,
      comment_count: 11735,
      digg_count: 511928,
      play_count: 0,
      share_count: 4059,
    },
    avatar:"https://p3-pc.douyinpic.com/img/aweme-avatar/mosaic-legacy_330b002fd56a93e8b6f1~c5_168x168.jpeg?from=2956013662",
    nickname: "李子柒",
    video_url: "https://www.douyin.com/aweme/v1/play/?video_id=v0200fa50000bqv2ovedm15352jvv5vg&line=0&file_id=efac24de9d2548228975fc8429e5bdcb&sign=3b7c4acc3b831e92448d6909510074c0&is_play_url=1&source=PackSourceEnum_PUBLISH",
  },
]
import _video from './components/utils/videolist'
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    buttons: [{
      text: '取消'
    }, {
      text: '确认'
    }],
    videoList: [],
    current_index: 0,
    moreFlag: true,
    page: 2,
    page_size: 10,
    videoId: 0,
    guideShow: false,
    index: 1,
    menuTop:44,
    statusBarHeight:22,
    theme:'',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      menuTop:app.globalData.menuTop,
      statusBarHeight:app.globalData.statusBarHeight,
      theme:app.globalData.theme
    })
    console.log(options,'options');
    let option = options
    if (options && options.scene) {
      const scene = decodeURIComponent(options.scene)
      let queryList = scene.split('&')
      for (let i = 0; i < queryList.length; i++) {
        const res = queryList[i];
        let key = res.split('=')
        if(key[0] === 'videoid'){
          option.liveid = key[1]
        }
      }
    }
    let videoid = 1
    if(option && option.videoid){
      videoid = option.videoid 
      // wx.navigateTo({
      //   url: '/pages/home/index?roomId='+option.liveid,
      // })
    }
    console.log(videoid);
    this.getData(videoid)
    return
    let that = this
    if (app.globalData.token) {
      that.getData()
    } else {
      app.getloginCallback = (v) => {
        if (v) {
          that.getData()
        }
      }
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
  goBack() {
    wx.navigateBack({
      delta: -1
    })
  },
  async getData(e) {
    let videoList = _video.filter((v,i)=>i<10)
    if(e!=1){
      const item = _video.find(f=>f.id==e)
      videoList = videoList.filter(f=>f.id!=e)
      if(videoList.length==10){
        videoList.pop()
      }
      videoList.unshift(item)
      this.setData({
        videoList
      })
    }else{
      this.setData({
        videoList
      })
    }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  onPlay(e) {},
  onPause() {},
  onTimeUpdate() {},
  onEnded() {},
  onError() {},
  onWaiting() {},
  onProgress() {},
  onLoadedMetaData(e) {},
  onPlayCurrent(e) {
    console.log(e.detail,'152');
    this.setData({
      videoId: e.detail
    })
  },
  async onUpdataVideo(e) {
    let videoList = this.data.videoList;
    let index = this.data.index
    if(index>10){
      index = 1
      this.setData({index})
    }
    let nextVideoList = _video.filter((v,i)=>(i>= index*10 && i<index * 2 * 10 ))
    // 模拟数据请求
    setTimeout(() => {
      for (let i = 0; i < 10; i++) {
        videoList.push(nextVideoList[i]);
      }
      this.setData({
        videoList
      });
      this.setData({index:index + 1})
    }, 1000)
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
   onShareAppMessage(e) {
     const {videoList,videoId} = this.data
     let _item = videoList.find(f=>f.id==videoId)
     let title = _item.nickname
    return {
      title ,
      path: '/pages/index/index?videoid=' + _item.id,
    }
  }
})